<?php

/**
* Wurfl.php
*
* Test user error handler
*
* @author     Blazej Zieba <b@zieba.info>
* @copyright  2007 konekto.com
* @version    CVS: $Id:$
*/
require_once '../config.php';
require_once 'simpletest/autorun.php';
require_once 'simpletest/web_tester.php';

require_once '../Wurfl.class.php';

class WurflTest extends WebTestCase
{


    function setUp()
    {

    }

    public function testE51()
    {
        $_SERVER['HTTP_USER_AGENT'] = "Mozilla/5.0(SymbianOS/9.2; U; Series60/3.1 NokiaE51/1.00.000; Profile/MIDP-2.0 Configuration/CLDC-1.1;)AppleWebKit/413(KHTML,like Gecko)Safari/413";
        $device = Wurfl::deviceFactory();
        $this->assertEqual('E51',$device->getCapability('model_name') );
        $this->assertEqual('320',Wurfl::getHeight() );        
        $this->assertEqual('229',Wurfl::getWidth() );
        $this->assertEqual(false,Wurfl::isTouchscreen());
        $this->assertEqual(true,Wurfl::isWireless());
    }

    public function testGenericWebBrowser()
    {
        $_SERVER['HTTP_USER_AGENT'] = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 (.NET CLR 3.5.30729) ";
        $device = Wurfl::deviceFactory();
        $this->assertEqual('3.5',$device->getCapability('model_name') );
        $this->assertEqual('480',Wurfl::getHeight() );        
        $this->assertEqual('640',Wurfl::getWidth() );
        $this->assertEqual(false,Wurfl::isTouchscreen());
        $this->assertEqual(false,Wurfl::isWireless());

    }

    public function testTouchScreen()
    {
        $_SERVER['HTTP_USER_AGENT'] = "Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3A101a Safari/419.3";
        $device = Wurfl::deviceFactory();
        $this->assertEqual(true,Wurfl::isTouchscreen());
        $this->assertEqual(true,Wurfl::isWireless());
    }
    
    public function testTransCoder()
    {
        $_SERVER['HTTP_USER_AGENT'] = "Opera/9.50 (J2ME/MIDP; Opera Mini/4.0.9800/209; U; en)";
        $_SERVER['HTTP_X_OPERAMINI_PHONE_UA'] = "Mozilla/5.0(SymbianOS/9.2; U; Series60/3.1 NokiaE51/1.00.000; Profile/MIDP-2.0 Configuration/CLDC-1.1;)AppleWebKit/413(KHTML,like Gecko)Safari/413";
        $device = Wurfl::deviceFactory();
        $this->assertEqual('E51',$device->getCapability('model_name') );
        $this->assertEqual('320',Wurfl::getHeight() );        
        $this->assertEqual('229',Wurfl::getWidth() );
        $this->assertEqual(false,Wurfl::isTouchscreen());
        $this->assertEqual(true,Wurfl::isWireless());
        
    }

    
    public function tearDown()
    {
        unSet($_SERVER);
        Wurfl::unSetDevice(); 
    }
    
}

?>
